home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 June / Software of the Month Club 1996 June.iso / mac / Education / Extended Calculator II / Calculator programs / Guessing game next >
Text File  |  1996-03-04  |  434b  |  22 lines

  1. a:=random(1,100);
  2. h:=100;
  3. l:=0;
  4. x:=get("Guess a number between 1 and 100!",int((h+l)/2));
  5. n:=1;
  6. while (x<>a);
  7.     if (x<a);
  8.         l:=x;
  9.         x:=get("Wrong, guess higher!",int((h+l)/2));
  10.     else;
  11.         h:=x;
  12.         x:=get("Wrong, guess lower!",int((h+l)/2));
  13.     end;
  14.     n:=n+1;
  15. end;
  16.  
  17. if (n=1);
  18.     show("Great kid, that was one in a million.",n);
  19. else;
  20.     show("You finally got it right. Total number of guesses:",n);
  21. end;
  22.